#ifndef _IHTTP_H_
#define _IHTTP_H_


typedef enum
{
	HTTP_IMPL_START = 0,

	HTTP_IMPL_CONNECTING,
	HTTP_IMPL_CONNECT_FAIL,
	HTTP_IMPL_CONNECTED,

	HTTP_IMPL_LOCATION,
	HTTP_IMPL_LOCATION_FAIL,
	HTTP_IMPL_LOCATIONED,

	HTTP_IMPL_SEND_HEAD,
	HTTP_IMPL_SEND_HEAD_FAIL,
	HTTP_IMPL_SEND_HEADED,

	HTTP_IMPL_SEND_BODY,
	HTTP_IMPL_SEND_BODY_FAIL,
	HTTP_IMPL_SEND_BODYED,

	HTTP_IMPL_RECV_HEAD,
	HTTP_IMPL_RECV_HEAD_FAIL,
	HTTP_IMPL_RECV_HEADED,

	HTTP_IMPL_RECV_BODY,
	HTTP_IMPL_RECV_BODY_FAIL,
	HTTP_IMPL_RECV_BODYED,

	HTTP_IMPL_END,

	HTTP_IMPL_UNKNOWN

}http_state_t;

typedef enum {



}http_s_state_t;


typedef enum
{
	HTTP_METHOD_UNKNOWN,   
	HTTP_METHOD_GET,        
	HTTP_METHOD_POST,       
	HTTP_METHOD_PUT,        
	HTTP_METHOD_CONNECT,   
	HTTP_METHOD_PURGE,     
	HTTP_METHOD_DELETE,     
	HTTP_METHOD_HEAD,     
	HTTP_METHOD_OPTION,    
	HTTP_METHOD_PROPFIND,	
	HTTP_METHOD_OTHER,	
}http_method_t;


typedef enum
{
	// Content-Type: application/x-www-form-urlencoded
	HTTP_REQUEST_NORMAL,

	// Content-Type: multipart/form-data; boundary=xxx
	HTTP_REQUEST_MULTIPART_FORM,

	// Content-Type: application/octet-stream
	HTTP_REQUEST_OCTET_STREAM,

	// Content-Type: text/xml
	HTTP_REQUEST_TEXT_XML,

	// Content-Type: text/json
	HTTP_REQUEST_TEXT_JSON,

	//
	HTTP_REQUEST_OTHER
} http_request_t;

typedef enum
{
	HTTP_MIME_PARAM,        // http mime param
	HTTP_MIME_FILE          // http mime file 
}http_mime_t;

typedef unsigned short	http_port;
typedef const char*		http_addr_s;
typedef const char*		http_header;
typedef const char*		http_header_data;
typedef const char*		http_method_name;

#define http_host_len	256

interface IHttpInstanceProc : public IBase
{
	std_method_(ULONG, Event)(ULONG ulevent) PURE;
	std_method_(ULONG, SendHead)(void* data, ULONG nSize, size_t nLen) PURE;
	std_method_(ULONG, SendBody)(void* data, ULONG nSize, size_t nLen) PURE;
	std_method_(ULONG, RecvHead)(void* data, ULONG nSize, size_t nLen) PURE;
	std_method_(ULONG, RecvBody)(void* data, ULONG nSize, size_t nLen) PURE;
};

// {8C102441-E383-4B3C-8CC8-7C8E0B0162FE}
_DEFINE_IID(IID_IHttpInstanceProc,
	0x8c102441, 0xe383, 0x4b3c, 0x8c, 0xc8, 0x7c, 0x8e, 0xb, 0x1, 0x62, 0xfe);


interface IHttpInstance : public IBase
{
	std_method(BindEvent)(IBase* pBase) PURE;
	std_method(UnBindEvent)() PURE;
	std_method(SetCookies)(http_header_data *data) PURE;
	std_method(Open)(http_addr_s url, http_addr_s scheme, http_port uport) PURE;
	std_method(ReSet)()	 PURE;
	std_method(Cancel)() PURE;
	std_method_(int, IsComplete)() PURE;
};

// {6014F5E1-05A9-476F-898C-8606756A750F}
_DEFINE_IID(IID_IHttpInstance,
	0x6014f5e1, 0x5a9, 0x476f, 0x89, 0x8c, 0x86, 0x6, 0x75, 0x6a, 0x75, 0xf);


interface IHttpApplicationProc : public IBase
{
	std_method(OnGetHost)(int error, LPCSTR hostname, LPCSTR host) PURE;
};

// {23C86623-C039-416B-A489-C175C360E692}
_DEFINE_IID(IID_IHttpApplicationProc,
	0x23c86623, 0xc039, 0x416b, 0xa4, 0x89, 0xc1, 0x75, 0xc3, 0x60, 0xe6, 0x92);

interface IHttpApplication : public IBase
{
	
};

// {75BD9CAF-2D0D-4408-B481-655F30F8613F}
_DEFINE_IID(IID_IHttpApplication,
	0x75bd9caf, 0x2d0d, 0x4408, 0xb4, 0x81, 0x65, 0x5f, 0x30, 0xf8, 0x61, 0x3f);

#endif
